﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="OrderDetail.aspx.cs" Inherits="OrderDetail" %>

<%@ Register assembly="DevExpress.Web.ASPxGridView.v10.2, Version=10.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridLookup" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.ASPxGridView.v10.2, Version=10.2.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dx" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
    <ContentTemplate>
        <asp:Label ID="_lblMessage" runat="server" Text=""></asp:Label>
        <asp:SqlDataSource ID="SqlDataSourceOrders" runat="server" 
            ConnectionString="<%$ ConnectionStrings:DB_BookStoreConnectionString %>" 
            SelectCommand="SELECT * FROM [Orders] WHERE ([UserID] = @UserID)">
            <SelectParameters>
                <asp:SessionParameter Name="UserID" SessionField="IdUser" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        <p style="text-align:center;">Vui lòng chọn đơn đặt hàng</p>
        <dx:ASPxGridLookup ID="ASPxGridLookup1" runat="server" 
            AutoGenerateColumns="False" DataSourceID="SqlDataSourceOrders" 
            KeyFieldName="ID" onvaluechanged="ASPxGridLookup1_ValueChanged" 
            AutoPostBack="True">
            <Columns>
                <dx:GridViewDataTextColumn FieldName="ID" ReadOnly="True" VisibleIndex="0">
                    <EditFormSettings Visible="False" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn FieldName="CustomerName" VisibleIndex="1">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn FieldName="CustomerAddress" VisibleIndex="2">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn FieldName="CustomerPhoneNo" VisibleIndex="3">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn FieldName="ReceiverName" VisibleIndex="4">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn FieldName="ReceiverPhoneNo" VisibleIndex="5">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn FieldName="ReceiverAddress" VisibleIndex="6">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataDateColumn FieldName="OrderDate" VisibleIndex="7">
                </dx:GridViewDataDateColumn>
                <dx:GridViewDataTextColumn FieldName="Total" VisibleIndex="8">
                </dx:GridViewDataTextColumn>
            </Columns>
    <GridViewProperties>
    <SettingsBehavior AllowFocusedRow="True" AllowSelectSingleRowOnly="True"></SettingsBehavior>
    </GridViewProperties>
        </dx:ASPxGridLookup>
        <asp:GridView ID="GridView1" runat="server" 
            AutoGenerateColumns="False" DataSourceID="SqlDataSource2">
            <Columns>
                <asp:BoundField DataField="ProductName" HeaderText="Tên sản phẩm" />
                <asp:TemplateField HeaderText="Hình">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Thumbnail") %>'></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("Thumbnail") %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="UnitPrice" HeaderText="Đơn giá" 
                    />
                <asp:BoundField DataField="Amount" HeaderText="Số lượng" 
                    />
            </Columns>
            
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:DB_BookStoreConnectionString %>" SelectCommand="SELECT ProductName, Thumbnail, UnitPrice, o.Amount
                FROM Products p INNER JOIN OrdersDetail o ON p.ProductID = o.ProductID
                WHERE OrderID =  @OrderID">
        <SelectParameters>
            <asp:ControlParameter ControlID="ASPxGridLookup1" Name="OrderID" 
                PropertyName="Value" />
        </SelectParameters>
    </asp:SqlDataSource>
    </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

